package com.music.checkpoints.api;

import com.music.checkpoints.common.service.ExamineeManager;
import com.music.checkpoints.common.utils.ResultVOUtil;
import com.music.checkpoints.common.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/machine/")
public class LoginController {
    @Autowired
    private ExamineeManager examineeManager;

    @PostMapping("/login")
    public ResultVO login(@RequestParam("exam_code") @NotEmpty(message = "准考证不能为空") String examCode) {
        return ResultVOUtil.success(examineeManager.login(examCode));
    }

    @Autowired
    @GetMapping("/version")
    public ResultVO version() {
        Map<String, String> map = new HashMap<>();
        map.put("version", "1.0.0");
        map.put("url", "http://resource.tsingmuth.com/exam1.0.0.apk");
        return ResultVOUtil.success(map);
    }
}
